package com.tebiecloud.store.server.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tebiecloud.base.client.constants.BaseConstants;
import com.tebiecloud.base.client.model.entity.BaseAccount;
import com.tebiecloud.common.constants.ResultEnum;
import com.tebiecloud.common.properties.CommonProperties;
import com.tebiecloud.common.security.SecurityHelper;
import com.tebiecloud.common.security.SecurityUserDetails;
import com.tebiecloud.common.utils.JsonUtils;
import com.tebiecloud.common.utils.RedisUtils;
import com.tebiecloud.common.utils.StringUtils;
import com.tebiecloud.order.client.model.entity.OrderStats1;
import com.tebiecloud.order.client.model.entity.Orderr;
import com.tebiecloud.store.client.constatns.StoreConstants;
import com.tebiecloud.store.client.model.entity.Store;
import com.tebiecloud.store.client.model.entity.StoreBankCard;
import com.tebiecloud.store.client.model.entity.StoreFlow;
import com.tebiecloud.store.client.model.entity.StoreStaff;
import com.tebiecloud.store.client.model.vo.StoreVO;
import com.tebiecloud.store.client.model.vo.WithdrawInfoVO;
import com.tebiecloud.store.server.service.StoreBankCardService;
import com.tebiecloud.store.server.service.StoreFlowService;
import com.tebiecloud.store.server.service.StoreService;
import com.tebiecloud.common.model.PageParams;
import com.tebiecloud.common.model.ResultBody;
import com.tebiecloud.common.utils.ResultBodyUtils;
import com.tebiecloud.store.server.service.StoreStaffService;
import com.tebiecloud.store.server.service.feign.*;
import com.tebiecloud.yunst.client.model.vo.BandCardVO;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * 门店表 前端控制器
 * @author tebie
 * @date 2019-09-15
 */
@Slf4j
@RestController
@RequestMapping("/store")
public class StoreController {

    @Autowired
    private StoreService storeService;

    @Autowired
    private StoreStaffService storeStaffService;

    @Autowired
    private StoreFlowService storeFlowService;

    @Autowired
    private OrderServiceClient orderServiceClient;

    @Autowired
    private Stats1ServiceClient stats1ServiceClient;

    @Autowired
    private YunWithdrawServiceClient yunWithdrawServiceClient;

    @Autowired
    private BaseUserServiceClient baseUserServiceClient;

    @Autowired
    private YunBankCardClient yunBankCardClient;

    @Autowired
    private StoreBankCardService storeBankCardService;

    /**
     * 获取附近门店
     * @param lng
     * @param lat
     * @return
     */
    @PostMapping(value = "listnearby")
    public ResultBody<List<StoreVO>> listnearby(
            @RequestParam(value = "lng", required = false) Double lng,
            @RequestParam(value = "lat", required = false) Double lat) {
        return ResultBodyUtils.ok(storeService.listNearby(lng,lat,null));
    }

    /**
     * 获取门店信息
     * @param storeId
     * @return
     */
    @PostMapping("info")
    public ResultBody<StoreVO> get(@RequestParam(value = "storeId",required = false) Long storeId) {
        if(storeId==null){
            //查询随意一家门店
            List<Store> storeList = storeService.list();
            if(storeList.size()>0){
                storeId = storeList.get(0).getStoreId();
            }else{
                log.info(">>minjie,没有查询到门店");
                return ResultBodyUtils.failed("没有查询到门店");
            }
        }
        StoreVO storeVO = storeService.info(storeId);
        //查询未核销金额
        if(storeId!=null){
            ResultBody<List<Orderr>> orderReultBody =  orderServiceClient.selectOrderList(storeId);
            if(orderReultBody!=null && orderReultBody.getCode() == ResultEnum.OK.getCode()){
                List<Orderr> orderrList = orderReultBody.getData();
                if(orderrList!=null && orderrList.size()>0){
                    int price = 0;
                    for(Orderr orderr:orderrList){
                        price = price + orderr.getPrice();
                    }
                    storeVO.setUnwrittenOffBalance(price);
                }
            }
        }
        return ResultBodyUtils.ok(storeVO);
    }

    /**
     * 会员列表
     * @param keyword
     * @param page
     * @param limit
     * @return
     */
    @PostMapping(value = "listmember")
    public ResultBody listmember(
            @RequestParam(value = "keyword", required = false) String keyword,
            @RequestParam(value = "storeId") long storeId,
            @RequestParam(value = "page", required = false,defaultValue = "1") int page,
            @RequestParam(value = "limit", required = false,defaultValue = "10") int limit) {
        ResultBody<Page<OrderStats1>> iPageResultBody = stats1ServiceClient.statsListPage(page,limit,storeId,keyword);
        if(iPageResultBody.getCode() == ResultEnum.OK.getCode()){
            Page<OrderStats1> orderStats1IPage = iPageResultBody.getData();
            return ResultBodyUtils.ok(orderStats1IPage);
        }
        return ResultBodyUtils.failed();
    }

    /**
     * 会员信息
     * @param unionid
     * @param storeId
     * @return
     */
    @PostMapping(value = "infomember")
    public ResultBody infomember(
            @RequestParam(value = "unionid") String unionid,
            @RequestParam(value = "storeId") long storeId) {
        ResultBody<OrderStats1> orderStats1ResultBody = stats1ServiceClient.statsInfo(unionid,storeId);
        if(orderStats1ResultBody.getCode() == ResultEnum.OK.getCode()){
            OrderStats1 orderStats1 = orderStats1ResultBody.getData();
            return  ResultBodyUtils.ok(orderStats1);
        }
        return ResultBodyUtils.failed();
    }

    /**
     * 更新备注名称
     * @param unionid
     * @param storeId
     * @param remarkName
     * @return
     */
    @PostMapping(value = "updatemember")
    public ResultBody updatemember(
            @RequestParam(value = "unionid") String unionid,
            @RequestParam(value = "storeId") long storeId,
            @RequestParam(value = "remarkName") String remarkName) {
        ResultBody<OrderStats1> orderStats1ResultBody = stats1ServiceClient.statsUpdate(unionid,storeId,remarkName);
        if(orderStats1ResultBody.getCode() == ResultEnum.OK.getCode()){
            return  ResultBodyUtils.ok();
        }
        return ResultBodyUtils.failed();
    }


    /**
     * 获取门店可提现信息
     * @return
     */
    @PostMapping("withdraw/Info")
    public ResultBody<WithdrawInfoVO> infoWithdraw(@RequestParam(value = "storeId") long storeId) {
        WithdrawInfoVO withdrawInfoVO = storeService.infoWithdraw(storeId);
        if(withdrawInfoVO == null){
            return ResultBodyUtils.failed("没有绑定银行卡，请联系管理员");
        }
        return ResultBodyUtils.ok(withdrawInfoVO);
    }

    /**
     * 门店提现
     * @param storeId 门店id
     * @param amount 金额：单位分
     * @return
     */
    @PostMapping("withdraw")
    public ResultBody withdraw(
            @RequestParam("storeId") long storeId,
            @RequestParam("amount") int amount) {
        SecurityUserDetails securityUserDetails = SecurityHelper.getUser();
        long userId = securityUserDetails.getUserId();
        //查询账户角色
        QueryWrapper<StoreStaff> storeStaffQueryWrapper = new QueryWrapper<>();
        storeStaffQueryWrapper.eq("user_id",userId);
        storeStaffQueryWrapper.eq("store_id",storeId);
        StoreStaff storeStaff = storeStaffService.getOne(storeStaffQueryWrapper);
        if(storeStaff==null){
            return  ResultBodyUtils.failed("您不在该门店");
        }
        if(!"MERCHANT".equals(storeStaff.getRoleCode())){
            return ResultBodyUtils.failed("您不是商户，权限不足");
        }
        if(amount<100){
            return ResultBodyUtils.failed("起提资金不能少于1元");
        }
        //查询用户余额
        QueryWrapper<Store> storeQueryWrapper = new QueryWrapper<>();
        storeQueryWrapper.eq("store_id",storeId);
        Store store = storeService.getOne(storeQueryWrapper);
        if(store==null){
            return ResultBodyUtils.failed("该门店不存在");
        }
        if(store.getBalance()<amount){
            return ResultBodyUtils.failed("账号余额不足");
        }
        ResultBody<com.tebiecloud.yunst.client.model.vo.WithdrawInfoVO> withdrawResult = yunWithdrawServiceClient.withdrawApply(userId,amount);
        if(withdrawResult!=null && withdrawResult.getCode()== ResultEnum.OK.getCode()){
            com.tebiecloud.yunst.client.model.vo.WithdrawInfoVO withdrawInfoVO1 = withdrawResult.getData();
            if(withdrawInfoVO1!=null){
                storeFlowService.saveFlow(storeId,Long.valueOf(withdrawInfoVO1.getNumber()),withdrawInfoVO1.getAmount(),2);
            }
        }else{
            return withdrawResult;
        }
        return ResultBodyUtils.ok();
    }


    /**
     * 门店模糊查询
     * @param page
     * @param limit
     * @param storeName 门店名称
     * @param storePhone 门店手机号
     * @param province 省份
     * @param city 城市
     * @param county 城镇
     * @param professionId 分类id
     * @param startTime //开始入驻时间
     * @param endTime //结束入驻时间
     * @return
     */
    @PostMapping(value = "listbycondition")
    public ResultBody<List<StoreVO>> listbycondition(
            @RequestParam(value = "page", required = false,defaultValue = "1") int page,
            @RequestParam(value = "limit", required = false,defaultValue = "10") int limit,
            @RequestParam(value = "storeName", required = false) String storeName,
            @RequestParam(value = "agmName", required = false) String agmName,
            @RequestParam(value = "storePhone", required = false) String storePhone,
            @RequestParam(value = "province", required = false) String province,
            @RequestParam(value = "city", required = false) String city,
            @RequestParam(value = "county", required = false) String county,
            @RequestParam(value = "professionId", required = false) Integer professionId,
            @RequestParam(value = "startTime", required = false) String startTime,
            @RequestParam(value = "endTime", required = false) String endTime) {
        IPage<StoreVO> storeVOIPage = storeService.listbycondition( page, limit, storeName,agmName,storePhone,
                province, city, county, professionId, startTime, endTime);
        return ResultBodyUtils.ok(storeVOIPage);
    }


    /**
     * 新增门店接口
     * @param storeName 门店名称,
     * @param image 门店logo
     * @param milieuicPic 门店环境图
     * @param professionIds 主营业务id，使用逗号隔开,
     * @param type 门店类型：1街店，2MALL店，3社区店,
     * @param province 省份,
     * @param city 城市,
     * @param county 镇,
     * @param address 详细地址,
     * @param lng 经度,
     * @param lat 纬度,
     * @param legalPerson 法人代表,
     * @param contactPhone 联系人电话,
     * @param storePhone 门店电话,
     * @param openStime 营业开始时间：ps：09:00,
     * @param openEtime 营业结束时间：ps：21:00,
     * @param remark 备注,
     * @param status 状态：0、禁用，1、启用,
     * @return
     */
    @PostMapping("createOrUpdate")
    public ResultBody createOrUpdate(
            @RequestParam(value = "userId", required = false) Long userId,
            @RequestParam(value = "storeId", required = false) Long storeId,
            @RequestParam(value = "storeName", required = false) String storeName,
            @RequestParam(value = "brand", required = false) String brand,
            @RequestParam(value = "image", required = false) String image,
            @RequestParam(value = "milieuicPic", required = false) String milieuicPic,
            @RequestParam(value = "professionIds", required = false) String professionIds,
            @RequestParam(value = "type", required = false) Integer type,
            @RequestParam(value = "province", required = false) String province,
            @RequestParam(value = "city", required = false) String city,
            @RequestParam(value = "county", required = false) String county,
            @RequestParam(value = "address", required = false) String address,
            @RequestParam(value = "lng", required = false) Double lng,
            @RequestParam(value = "lat", required = false) Double lat,
            @RequestParam(value = "legalPerson", required = false) String legalPerson,
            @RequestParam(value = "contactPhone", required = false) String contactPhone,
            @RequestParam(value = "storePhone", required = false) String storePhone,
            @RequestParam(value = "openStime", required = false) String openStime,
            @RequestParam(value = "openEtime", required = false) String openEtime,
            @RequestParam(value = "remark", required = false) String remark,
            @RequestParam(value = "status", required = false) Integer status,
            @RequestParam(value = "account", required = false) String account,
            @RequestParam(value = "password", required = false) String password,
            @RequestParam(value = "rePassword", required = false) String rePassword,
            @RequestParam(value = "cardNo", required = false) String cardNo,
            @RequestParam(value = "identityNo", required = false) String identityNo,
            @RequestParam(value = "realname", required = false) String realname,
            @RequestParam(value = "phone", required = false) String phone) {

        if(userId == null){
            if(StringUtils.isEmpty(account)) return ResultBodyUtils.failedMsg("账户不能为空");
            if(StringUtils.isNotEmpty(password) && StringUtils.isNotEmpty(rePassword)){
                if(!password.equals(rePassword)) return ResultBodyUtils.failedMsg("两次密码不一致");
            }else {
                return ResultBodyUtils.failedMsg("两次密码不能为空");
            }
            ResultBody<BaseAccount> baseAccountResultBody = saveAccount(account,password);
            if(baseAccountResultBody.getCode() == ResultEnum.OK.getCode()){
                BaseAccount baseAccount = baseAccountResultBody.getData();
                if(baseAccount !=null ) userId = baseAccount.getUserId();
            }else {
                return baseAccountResultBody;
            }
        }
        if(userId == null) return ResultBodyUtils.failedMsg("新增账户失败");
        Store store = new Store();
        store.setStoreId(storeId);
        store.setName(storeName);
        store.setBrand(brand);
        store.setImage(image);
        store.setMilieuPic(milieuicPic);
        store.setProfessionIds(professionIds);
        store.setType(type);
        store.setProvince(province);
        store.setCity(city);
        store.setCounty(county);
        store.setAddress(address);
        store.setLng(lng);
        store.setLat(lat);
        store.setLegalPerson(legalPerson);
        store.setContactPhone(contactPhone);
        store.setStorePhone(storePhone);
        store.setOpenStime(openStime);
        store.setOpenEtime(openEtime);
        store.setRemark(remark);
        store.setStatus(status);
        store.setDeleted(0);
        ResultBody<Store> storeResultBody = saveStore(store);
        if(storeResultBody.getCode() == ResultEnum.OK.getCode()){
            store = storeResultBody.getData();
        }else{
            return storeResultBody;
        }
        Map<String,Object> resultMap = new HashMap<>();
        if(store.getStoreId() != null && userId != null){//保存好账户门店信息后，新增银行卡
            if(StringUtils.isNotEmpty(cardNo) && StringUtils.isNotEmpty(identityNo)
                    && StringUtils.isNotEmpty(realname) && StringUtils.isNotEmpty(phone)){
                ResultBody<BandCardVO> bandCardVOResultBody = addBankCard(userId,store.getStoreId(),cardNo,identityNo,realname,phone);
                if(bandCardVOResultBody.getCode() == ResultEnum.OK.getCode()){
                    resultMap.put("isBand",1);
                }else if(bandCardVOResultBody.getCode() == com.tebiecloud.yunst.client.constants.ResultEnum.YUN_ST_CARD_EXIT.getCode()){
                    resultMap.put("isBand",1);
                }else {
                    resultMap.put("isBand",0);
                    resultMap.put("msg",bandCardVOResultBody.getMsg());
                }
            }else {
                resultMap.put("isBand",0);
                resultMap.put("msg","上传信息不全");
            }
        }
        resultMap.put("storeId",store.getStoreId());
        resultMap.put("userId",userId);
        return ResultBodyUtils.ok(resultMap);
    }

    /**
     * 更新门店状态
     * @param storeId
     * @param status
     * @return
     */
    @PostMapping("updateStauts")
    public ResultBody updateStauts(
            @RequestParam(value = "storeId", required = false) Long storeId,
            @RequestParam(value = "status", required = false) int status) {
        Store store = new Store();
        store.setStoreId(storeId);
        store.setStatus(status);
        if(storeService.updateById(store)){
            //查询商户号
            QueryWrapper<StoreStaff> storeStaffQueryWrapper = new QueryWrapper<>();
            storeStaffQueryWrapper.eq("store_id",storeId);
            storeStaffQueryWrapper.eq("role_code",StoreConstants.STORE_STAFF_MERCHANT);
            storeStaffQueryWrapper.last("LIMIT 1");
            StoreStaff storeStaff = storeStaffService.getOne(storeStaffQueryWrapper);
            //处理商户号登陆
            if(storeStaff!=null && storeStaff.getUserId()!=null){
                //获取账号
                ResultBody<BaseAccount> baseAccountResultBody = baseUserServiceClient.getBaseAccountByUserId(storeStaff.getUserId());
                if(baseAccountResultBody!=null && baseAccountResultBody.getCode() == ResultEnum.OK.getCode()){
                    BaseAccount baseAccount = baseAccountResultBody.getData();
                    if(baseAccount!=null){
                        baseUserServiceClient.updateBaseAccount(baseAccount.getAccount(),status);
                    }
                }
            }
        }
        return ResultBodyUtils.ok();
    }

    /**
     *新建或者更新门店
     * @return
     */
    private ResultBody<Store> saveStore(Store store){
        if(store.getStoreId()!=null){
            //查询
            QueryWrapper<Store> storeQueryWrapper = new QueryWrapper<>();
            storeQueryWrapper.eq("store_id",store.getStoreId());
            Store store1 = storeService.getOne(storeQueryWrapper);
            if(store1==null) return ResultBodyUtils.failedMsg("查询门店不存在");
            //更新
            UpdateWrapper<Store> storeUpdateWrapper = new UpdateWrapper<>();
            storeUpdateWrapper.eq("store_id",store.getStoreId());
            if(storeService.update(store,storeUpdateWrapper)){
                return ResultBodyUtils.ok(store);
            }
            return ResultBodyUtils.failedMsg("门店更新失败");
        }else{
            if(storeService.save(store)){
                return ResultBodyUtils.ok(store);
            }
            return ResultBodyUtils.failedMsg("门店新增失败");
        }
    }

    /**
     * 新建用户
     * @param account
     * @param password
     * @return
     */
    private ResultBody<BaseAccount> saveAccount(String account,String password){
        BaseAccount baseAccount = null;
        //保存登录账户
        ResultBody<BaseAccount> baseAccountResultBody = baseUserServiceClient.getBaseAccount(account, BaseConstants.ACCOUNT_TYPE_STORE_ACCOUNT,BaseConstants.ACCOUNT_DOMAIN_USER);
        if(baseAccountResultBody!=null && baseAccountResultBody.getCode() == ResultEnum.OK.getCode()){
            baseAccount = baseAccountResultBody.getData();
            if(baseAccount!=null)return ResultBodyUtils.failedMsg("账户已存在");
        }
        //添加账户
        String userDesc = "商户账户";
        ResultBody<BaseAccount> baseAccountResultBody1 = baseUserServiceClient.addBaseAccount(account,password,BaseConstants.ACCOUNT_TYPE_STORE_ACCOUNT,BaseConstants.ACCOUNT_DOMAIN_USER,userDesc,null,null);
        if(baseAccountResultBody1!=null && baseAccountResultBody1.getCode() == ResultEnum.OK.getCode()){
            baseAccount = baseAccountResultBody1.getData();
            if(baseAccount==null)return ResultBodyUtils.failedMsg("新增账户失败");
        }
        return ResultBodyUtils.ok(baseAccount);
    }

    private ResultBody<BandCardVO> addBankCard(Long userId,Long storeId,String cardNo,String identityNo,String realname,String phone){
        String openId = "o5rgm0vpxFJjIWOtwNw7zjjrguhk";//固定的openId
        //保存成功后添加门店关联账户
        StoreStaff storeStaff = new StoreStaff();
        storeStaff.setUserId(userId);
        storeStaff.setStoreId(storeId);
        storeStaff.setRoleCode(StoreConstants.STORE_STAFF_MERCHANT);
        storeStaff.setEntryTime(new Date());
        storeStaff.setHeadimgurl("https://mggwx.oss-cn-shenzhen.aliyuncs.com/gumiho/shop/image/20190516/260220859b9f485e8cbd6b193f62cc78.png");
        storeStaff.setName("商户");
        storeStaff.setSex(0);
        storeStaffService.save(storeStaff);
        //添加银行卡
        ResultBody<BandCardVO> bandCardVOResultBody = yunBankCardClient.applyBindBankCard(userId,phone,cardNo,realname,identityNo,openId);
        if(bandCardVOResultBody!=null && bandCardVOResultBody.getCode() == com.tebiecloud.common.constants.ResultEnum.OK.getCode()){
            BandCardVO bandCardVO = bandCardVOResultBody.getData();
            //把之前的卡设置禁用
            UpdateWrapper<StoreBankCard> storeBankCardUpdateWrapper = new UpdateWrapper<>();
            storeBankCardUpdateWrapper.eq("store_id",storeId);
            StoreBankCard storeBankCard = new StoreBankCard();
            storeBankCard.setStatus(0);
            storeBankCardService.update(storeBankCard,storeBankCardUpdateWrapper);

            //先查询是否已经绑过该卡
            QueryWrapper<StoreBankCard> storeBankCardQueryWrapper = new QueryWrapper<>();
            storeBankCardQueryWrapper.eq("store_id",storeId);
            storeBankCardQueryWrapper.eq("card_no",cardNo);
            StoreBankCard storeBankCard1 = storeBankCardService.getOne(storeBankCardQueryWrapper);
            if(storeBankCard1!=null){
                UpdateWrapper<StoreBankCard> storeBankCardUpdateWrapper1 = new UpdateWrapper<>();
                storeBankCardUpdateWrapper1.eq("store_bank_card_id",storeBankCard1.getStoreBankCardId());
                StoreBankCard storeBankCard2 = new StoreBankCard();
                storeBankCard2.setStatus(1);
                storeBankCardService.update(storeBankCard2,storeBankCardUpdateWrapper1);
            }else{
                StoreBankCard storeBankCard2 = new StoreBankCard();
                storeBankCard2.setCardNo(cardNo);
                storeBankCard2.setStoreId(storeId);
                storeBankCard2.setIdentityNo(identityNo);
                storeBankCard2.setName(realname);
                storeBankCard2.setPhone(phone);
                storeBankCard2.setIcon(bandCardVO.getIcon());
                storeBankCard2.setBank(bandCardVO.getBank());
                storeBankCard2.setType(bandCardVO.getType());
                storeBankCard2.setStatus(1);
                storeBankCard2.setBind(3);
                storeBankCardService.save(storeBankCard2);
            }
        }else{
            return bandCardVOResultBody;
        }
        return ResultBodyUtils.ok();
    }

//
//    /**
//     * 更新数据
//     * @param userId 登录账号userId
//     * @param name 门店名称
//     * @param professionIds 主营业务id，使用逗号隔开
//     * @param type 门店类型：1街店，2MALL店，3社区店
//     * @param province 省份
//     * @param city 城市
//     * @param county 镇
//     * @param address 详细地址
//     * @param lng 经度
//     * @param lat 纬度
//     * @param legalPerson 法人代表
//     * @param contactPhone 联系人电话
//     * @param storePhone 门店电话
//     * @param openStime 营业开始时间：ps：09:00
//     * @param openEtime 营业结束时间：ps：21:00
//     * @param remark 备注
//     * @param sort 排序，数值越小排越前
//     * @param status 状态：0、禁用，1、启用
//     * @param balance 门店余额
//     * @param deleted 删除状态：0没有删除1已被删除
//     * @return
//     */
//    @PostMapping("update")
//    public ResultBody update(
//            @RequestParam(value = "storeId", required = false) Long storeId,
//            @RequestParam(value = "userId", required = false) Long userId,
//            @RequestParam(value = "name", required = false) String name,
//            @RequestParam(value = "professionIds", required = false) String professionIds,
//            @RequestParam(value = "type", required = false) Integer type,
//            @RequestParam(value = "province", required = false) String province,
//            @RequestParam(value = "city", required = false) String city,
//            @RequestParam(value = "county", required = false) String county,
//            @RequestParam(value = "address", required = false) String address,
//            @RequestParam(value = "lng", required = false) Double lng,
//            @RequestParam(value = "lat", required = false) Double lat,
//            @RequestParam(value = "legalPerson", required = false) String legalPerson,
//            @RequestParam(value = "contactPhone", required = false) String contactPhone,
//            @RequestParam(value = "storePhone", required = false) String storePhone,
//            @RequestParam(value = "openStime", required = false) String openStime,
//            @RequestParam(value = "openEtime", required = false) String openEtime,
//            @RequestParam(value = "remark", required = false) String remark,
//            @RequestParam(value = "sort", required = false) Integer sort,
//            @RequestParam(value = "status", required = false) Integer status,
//            @RequestParam(value = "balance", required = false) Integer balance,
//            @RequestParam(value = "deleted", required = false) Integer deleted
//    ) {
//        Store entity = new Store();
//        entity.setStoreId(storeId);
//        entity.setUserId(userId);
//        entity.setName(name);
//        entity.setProfessionIds(professionIds);
//        entity.setType(type);
//        entity.setProvince(province);
//        entity.setCity(city);
//        entity.setCounty(county);
//        entity.setAddress(address);
//        entity.setLng(lng);
//        entity.setLat(lat);
//        entity.setLegalPerson(legalPerson);
//        entity.setContactPhone(contactPhone);
//        entity.setStorePhone(storePhone);
//        entity.setOpenStime(openStime);
//        entity.setOpenEtime(openEtime);
//        entity.setRemark(remark);
//        entity.setSort(sort);
//        entity.setStatus(status);
//        entity.setBalance(balance);
//        entity.setDeleted(deleted);
//        storeService.updateById(entity);
//        return ResultBodyUtils.ok();
//    }
//
//    /**
//     * 删除数据
//     * @param id 单个id
//     * @param ids 多个id用,号隔开
//     * @return
//     */
//    @PostMapping("remove")
//    public ResultBody remove(
//            @RequestParam(value = "id", required = false) Long id,
//            @RequestParam(value = "ids", required = false) String ids
//    ) {
//        if(id != null && id > 0) {
//            storeService.removeById(id);
//        }
//        if(ids != null && ids.length() > 0) {
//            storeService.removeByIds(Arrays.asList(ids.split(",")));
//        }
//        return ResultBodyUtils.ok();
//    }

}
